<!--
 * @Author: 陈俊升 761723995@qq.com
 * @Date: 2023-05-11 08:47:22
 * @LastEditors: 陈俊升 761723995@qq.com
 * @LastEditTime: 2024-02-21 09:50:45
 * @FilePath: /hr_new_vue3/src/views/Management/Human/HumanRoster/FileDetail/Components/Container/ChangeRecord/index.vue
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<!-- 人员档案详情-异动记录 -->
<template>
  <div class="wrap">
    <a-tabs default-active-key="1">
      <a-tab-pane key="1" title="人事异动"
        ><PersonChange :data="tableData.data" />
      </a-tab-pane>
      <a-tab-pane key="2" title="薪酬调整"> Content of Tab Panel 2 </a-tab-pane>
      <a-tab-pane key="3" title="劳动合同"> </a-tab-pane>
      <a-tab-pane key="4" title="社保公积金"> </a-tab-pane>
    </a-tabs>
  </div>
</template>

<script lang="ts" setup>
import { GetHumanRosterDetail } from '@/apis/management/human/humanRoster';
import { GetTransactionDetailList } from '@/apis/management/personnel/changeManagement/transactionManagement';
import {
  getListData,
  IneedSwitchArr,
  Idata
} from '@/utils/getAllSwitchListData';
import { flatTree, dataTreeFilter, downloadExcelFile } from '@/utils/utils';
import PersonChange from './Components/PersonChange/index.vue';

const route = useRoute();

let id = Number(route.query.id);

onBeforeRouteUpdate((to) => {
  id = Number(to.query.id);
  getData();
});

const needSwitchArr: IneedSwitchArr[] = [
  'organization',
  'organizationType',
  'human',
  'organization',
  'position',
  'positionType',
  'positionHierarchy',
  'job',
  'law',
  'workplace',
  'contractType',
  'transactionType'
];

const tableData: { data: Idata & { personDetail: any } } = reactive({
  data: {
    humanRosterList: [], // 人员列表
    organizationList: [], // 组织列表
    organizationTypeList: [], // 组织类型
    positionList: [], // 职位列表
    positionTypeList: [], // 职位类别列表
    positionHierarchyList: [], // 职位层级
    jobList: [], // 职务列表
    lawList: [], // 法律实体列表
    workplaceList: [], // 工作地点列表
    contractTypeList: [], // 合同类型列表}
    personDetail: {} // 人员详情
  }
});
const getData = async () => {
  try {
    tableData.data = (await getListData(needSwitchArr)) as Idata;
    tableData.data.personDetail = await GetHumanRosterDetail({ id });
    tableData.data.personDetail.ctlValue.forEach((el: any) => {
      tableData.data.personDetail[el.ctlCode] = el.ctlValue;
    });
    console.log('=======tableDatatableData=============================');
    console.log(tableData.data);
    console.log('====================================');
  } catch (error: unknown) {
    console.log(error);
  }
};
getData();
</script>

<style lang="less" scoped>
.wrap {
  display: flex;
}
</style>
